package com.mm.dictionary.listener;

import com.mm.dictionary.service.WordServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class AnalysisListener {
    private final WordServiceImpl wordService;

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "dic.analysis.queue"),
            exchange = @Exchange(name = "knowTree.direct"),
            key = "dic.analysis"
    ))
    public void listenPaySuccess(String text){
        try {
            System.out.println(text);
            wordService.analysisText(text);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
